In [1]:
import pandas as pd
import plotly.graph_objects as go
/Users/chandrasekharbotcha/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning:

numpy.ufunc size changed, may indicate binary incompatibility. Expected 192 from C header, got 216 from PyObject

/Users/chandrasekharbotcha/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning:

numpy.ufunc size changed, may indicate binary incompatibility. Expected 192 from C header, got 216 from PyObject

In [2]:
df = pd.read_csv('data/2011_US_AGRI_Exports')
In [3]:
df.head()
Out[3]:
code state category total exports beef pork poultry dairy fruits fresh fruits proc total fruits veggies fresh veggies proc total veggies corn wheat cotton text
0 AL Alabama state 1390.63 34.4 10.6 481.0 4.06 8.0 17.1 25.11 5.5 8.9 14.33 34.9 70.0 317.61 Alabama<br>Beef 34.4 Dairy 4.06<br>Fruits 25.1...
1 AK Alaska state 13.31 0.2 0.1 0.0 0.19 0.0 0.0 0.00 0.6 1.0 1.56 0.0 0.0 0.00 Alaska<br>Beef 0.2 Dairy 0.19<br>Fruits 0.0 Ve...
2 AZ Arizona state 1463.17 71.3 17.9 0.0 105.48 19.3 41.0 60.27 147.5 239.4 386.91 7.3 48.7 423.95 Arizona<br>Beef 71.3 Dairy 105.48<br>Fruits 60...
3 AR Arkansas state 3586.02 53.2 29.4 562.9 3.53 2.2 4.7 6.88 4.4 7.1 11.45 69.5 114.5 665.44 Arkansas<br>Beef 53.2 Dairy 3.53<br>Fruits 6.8...
4 CA California state 16472.88 228.7 11.1 225.4 929.95 2791.8 5944.6 8736.40 803.2 1303.5 2106.79 34.6 249.3 1064.95 California<br>Beef 228.7 Dairy 929.95<br>Frui...
In [5]:
fig = go.Figure(data=go.Choropleth(
        locations = df['code'], # spatial co-ordinates
        z = df['total exports'].astype(float), # Data to be color-coded
        locationmode = 'USA-states', # set of location match entries in 'locations'
        colorscale= 'reds',
        colorbar_title = "Millions USD"
            ))
In [6]:
fig.update_layout(
    title_text = '2011 US Agriculture Exports by State',
    geo_scope = 'usa')
fig.show()
In [8]:
fig = go.Figure(data=go.Choropleth(
        locations=['TX','CA','NY'], # spatial co-ordinates
        z = [1.0,2.0,3.0], # Data to be color-coded
        locationmode = 'USA-states', # set of location match entries in 'locations'
        colorscale= 'portland',
        text=['t1','t2','t3']
            ))

fig.update_layout(
    title_text = 'Three states study',
    geo_scope = 'usa')
fig.show()
In [9]:
df = pd.read_csv('data/2014_World_GDP')
df.head()
Out[9]:
COUNTRY GDP (BILLIONS) CODE
0 Afghanistan 21.71 AFG
1 Albania 13.40 ALB
2 Algeria 227.80 DZA
3 American Samoa 0.75 ASM
4 Andorra 4.80 AND
In [12]:
fig = go.Figure(data=go.Choropleth(
        locations = df['CODE'], # spatial co-ordinates
        z = df['GDP (BILLIONS)'], # Data to be color-coded
        
        colorscale= 'reds',
        colorbar_title = "GDP BILLIONS US$"
            ))


fig.update_layout(
    title_text = 'World GDP study',
    geo= dict(
        showframe=True,
        showcoastlines=False,
        projection_type='equirectangular'
        
    
    ))
fig.show()
In [ ]:
 
Untitled
In [1]:
import pandas as pd
import plotly.graph_objects as go
/Users/chandrasekharbotcha/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning:

numpy.ufunc size changed, may indicate binary incompatibility. Expected 192 from C header, got 216 from PyObject

/Users/chandrasekharbotcha/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning:

numpy.ufunc size changed, may indicate binary incompatibility. Expected 192 from C header, got 216 from PyObject

In [2]:
df = pd.read_csv('data/2011_US_AGRI_Exports')
In [3]:
df.head()
Out[3]:
code state category total exports beef pork poultry dairy fruits fresh fruits proc total fruits veggies fresh veggies proc total veggies corn wheat cotton text
0 AL Alabama state 1390.63 34.4 10.6 481.0 4.06 8.0 17.1 25.11 5.5 8.9 14.33 34.9 70.0 317.61 Alabama<br>Beef 34.4 Dairy 4.06<br>Fruits 25.1...
1 AK Alaska state 13.31 0.2 0.1 0.0 0.19 0.0 0.0 0.00 0.6 1.0 1.56 0.0 0.0 0.00 Alaska<br>Beef 0.2 Dairy 0.19<br>Fruits 0.0 Ve...
2 AZ Arizona state 1463.17 71.3 17.9 0.0 105.48 19.3 41.0 60.27 147.5 239.4 386.91 7.3 48.7 423.95 Arizona<br>Beef 71.3 Dairy 105.48<br>Fruits 60...
3 AR Arkansas state 3586.02 53.2 29.4 562.9 3.53 2.2 4.7 6.88 4.4 7.1 11.45 69.5 114.5 665.44 Arkansas<br>Beef 53.2 Dairy 3.53<br>Fruits 6.8...
4 CA California state 16472.88 228.7 11.1 225.4 929.95 2791.8 5944.6 8736.40 803.2 1303.5 2106.79 34.6 249.3 1064.95 California<br>Beef 228.7 Dairy 929.95<br>Frui...
In [5]:
fig = go.Figure(data=go.Choropleth(
        locations = df['code'], # spatial co-ordinates
        z = df['total exports'].astype(float), # Data to be color-coded
        locationmode = 'USA-states', # set of location match entries in 'locations'
        colorscale= 'reds',
        colorbar_title = "Millions USD"
            ))
In [6]:
fig.update_layout(
    title_text = '2011 US Agriculture Exports by State',
    geo_scope = 'usa')
fig.show()
In [8]:
fig = go.Figure(data=go.Choropleth(
        locations=['TX','CA','NY'], # spatial co-ordinates
        z = [1.0,2.0,3.0], # Data to be color-coded
        locationmode = 'USA-states', # set of location match entries in 'locations'
        colorscale= 'portland',
        text=['t1','t2','t3']
            ))

fig.update_layout(
    title_text = 'Three states study',
    geo_scope = 'usa')
fig.show()
In [9]:
df = pd.read_csv('data/2014_World_GDP')
df.head()
Out[9]:
COUNTRY GDP (BILLIONS) CODE
0 Afghanistan 21.71 AFG
1 Albania 13.40 ALB
2 Algeria 227.80 DZA
3 American Samoa 0.75 ASM
4 Andorra 4.80 AND
In [12]:
fig = go.Figure(data=go.Choropleth(
        locations = df['CODE'], # spatial co-ordinates
        z = df['GDP (BILLIONS)'], # Data to be color-coded
        
        colorscale= 'reds',
        colorbar_title = "GDP BILLIONS US$"
            ))


fig.update_layout(
    title_text = 'World GDP study',
    geo= dict(
        showframe=True,
        showcoastlines=False,
        projection_type='equirectangular'
        
    
    ))
fig.show()
In [ ]: